﻿/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_GB_DATA_TYPE_H
#define MK_GB_DATA_TYPE_H
#include "MkSip/MkSipUtil.h"
#include "MkUtil/MkTime.h"
#include "MkSip/MkSipServer.h"

#define MkGbIdLen           20
#define InvalidValue       -1

typedef enum _mk_gb_message_type
{
    //special message
    MkGbMessageAuthor,
    MkGbMessageRegister,

    //device control messages  A 2.3.1
    MkGbMessagePtzControl,
    MkGbMessageRebootDevice,
    MkGbMessageManualRecord,
    MkGbMessageResetAlarm,
    MkGbMessageAlarmGuard,
    MkGbMessageKeyFrame,
    MkGbMessageDragZoom,    //include drag zoom in and drag zoom out
    MkGbMessageHomePosition,
    MkGbMessagePtzPreciseControl,
    MkGbMessageSDCardFormat,
    MkGbMessageTargetTrack,
    MkGbMessageDeviceUpgrade,

    //device config messages A 2,3.2
    MkGbMessageSetBasicParam,
    MkGbMessageSetSvacEncodeConfig,
    MkGbMessageSetSvacDecodeConfig,
    MkGbMessageSetVideoParamAttribute,
    MkGbMessageSetVideoRecordPlan,
    MkGbMessageSetAlarmRecord,
    MkGbMessageSetPictureMask,
    MkGbMessageSetFrameMirror,
    MkGbMessageSetAlarmReport,
    MkGbMessageSetOsdConfig,
    MkGbMessageSetSnapShotConfig,

    //query  A 2.4.3
    MkGbMessageGetDeviceStatus,
    MkGbMessageGetCatalog,
    MkGbMessageGetDeviceInfo,
    MkGbMessageGetRecordInfo,
    MkGbMessageGetDeviceConfig, //A 2.4.7 configdownload
    MkGbMessageGetPreset,
    MkGbMessageGetHomePosition,
    MkGbMessageGetCruiseTrackList,
    MkGbMessageGetCruiseTrack,
    MkGbMessageGetPtzPosition,  //A 2.4.13
    MkGbMessageGetSdCardStatus,

    //subscribe
    MkGbMessageBroadcast,
    MkGbMessageAlarmSubscribe,   //A 2.4.6
    MkGbMessageCatalogSubscribe,
    MkGbMessageMobilePositionSubscribe, //A 2.4.9
    MkGbMessagePtzPositionSubscribe,  //A 2.4.13

    //notify
    MkGbMessageKeepAlive,       //A2.5.2
    MkGbMessageCatalogNotify,
    MkGbMessageDeviceUpgradeNotify,
    MkGbMessageSnapshotEndNotify,
    MkGbMessageVideoUploadNotify,
    MkGbMessageAlarmNotify,
    MkGbMessageMediaStatusNotify,
    MkGbMessageMobilePositionNotify,
    MkGbMessageBroadcastNotify,

    //has response messages

    //has response and request has param messages
    MkGbMessageSnapShot,

    //invite bye
    MkGbMessageInvite,
    MkGbMessagePlayControl,
    MkGbMessageBye,
    MkGbMessageCancel,
    MkGbMessagePlayEnd,

    MkGbMessageEnd  //flag
} MkGbMessageType;

typedef enum _gb_28181_error_code
{

}MkGb28181ErrorCode;

// define value to gb 28181
/*                                          0-FF                 0-FF                 0-F             */
/*  ptz command                    |       param 1    |        param2       |       param3          | */
/*  MkGbPtzStop                    |         0        |          0          |         0             | */
/*  MkGbPtzUp                      |         0        |        speed        |         0             | */
/*  MkGbPtzDown                    |         0        |        speed        |         0             | */
/*  MkGbPtzLeft                    |       speed      |          0          |         0             | */
/*  MkGbPtzRight                   |       speed      |          0          |         0             | */
/*  MkGbPtzLeftUp                  |     level speed  |     vertical speed  |         0             | */
/*  MkGbPtzLeftDown                |     level speed  |     vertical speed  |         0             | */
/*  MkGbPtzRightUp                 |     level speed  |     vertical speed  |         0             | */
/*  MkGbPtzRightDown               |     level speed  |     vertical speed  |         0             | */
/*  MkGbPtzNear                    |      speed       |          0          |         0             | */
/*  MkGbPtzFar                     |      speed       |          0          |         0             | */
/*  MkGbPtzZoomIn                  |        0         |          0          |        speed          | */
/*  MkGbPtzZoomOut                 |        0         |          0          |        speed          | */
/*  MkGbPtzApertuerBig             |        0         |        speed        |         0             | */
/*  MkGbPtzApertuerSmall           |        0         |        speed        |         0             | */
/*  MkGbPtzSetPreset               |        0         |       preset id     |         0             | */
/*  MkGbPtzClearPreset             |        0         |       preset id     |         0             | */
/*  MkGbPtzCallPreset              |        0         |       preset id     |         0             | */
/*  MkGbPtzAddCruise               |      cruise id   |       preset id     |         0             | */
/*  MkGbPtzDelCruise               |      cruise id   |       preset id     |         0             | */
/*  MkGbPtzCruiseSpeed             |      cruise id   |       preset id     |        speed          | */
/*  MkGbPtzCruiseStayTime          |      cruise id   |       preset id     |        stay time      | */
/*  MkGbPtzRunCruise               |      cruise id   |          0          |         0             | */
/*  MkGbPtzRunAutoScan             |      scan id     |        0 scan       |         0             | */
/*  MkGbPtzRunAutoScan             |      scan id     |      1 left scan    |         0             | */
/*  MkGbPtzRunAutoScan             |      scan id     |      2 right scan   |         0             | */
/*  MkGbPtzAutoScanSpeed           |      scan id     |    scan speed low   |    scan speed high    | */
/*  MkGbPtzSwithOn MkPtzSwithOff   |      1 wiper     |          0          |         0             | */
typedef enum _ptz_command_type
{
    MkGbPtzStop = 0x00,
    MkGbPtzUp = 0x08,
    MkGbPtzDown = 0x04,
    MkGbPtzLeft = 0x02,
    MkGbPtzRight = 0x01,
    MkGbPtzLeftUp = MkGbPtzLeft | MkGbPtzUp,
    MkGbPtzLeftDown = MkGbPtzLeft | MkGbPtzDown,
    MkGbPtzRightUp = MkGbPtzRight | MkGbPtzUp,
    MkGbPtzRightDown = MkGbPtzRight | MkGbPtzDown,
    MkGbPtzNear = 0x42,  //focus
    MkGbPtzFar = 0x41,
    MkGbPtzZoomIn = 0x10,
    MkGbPtzZoomOut = 0x20,
    MkGbPtzApertuerBig = 0x44,  //Iris
    MkGbPtzApertuerSmall = 0x48,
    MkGbPtzSetPreset = 0x81,
    MkGbPtzCallPreset = 0x82,
    MkGbPtzClearPreset = 0x83,
    MkGbPtzAddCruise = 0x84,
    MkGbPtzDelCruise = 0x85,
    MkGbPtzCruiseSpeed = 0x86,
    MkGbPtzCruiseStayTime = 0x87,
    MkGbPtzRunCruise = 0x88,
    MkGbPtzRunAutoScan = 0x89,
    MkGbPtzAutoScanSpeed = 0x8A,
    MkGbPtzSwithOn = 0x8C,
    MkGbPtzSwitchOff = 0x8D
}MkGbPtzCommandType;

//typedef enum _result_type
//{
//    MkGbOk,
//    MkGbError,
//}MkGbResultType;

//typedef enum _status_type
//{
//    MkGbOn,
//    MkGbOff,
//}MkGbStatusType;

//typedef enum _online_type
//{
//    MkGbOnline,
//    MkGbOffline
//}MkGbOnlineType;

//typedef enum _record_cmd_type
//{
//    MkGbRecord,
//    MkGbStopRecord
//}MkGbRecordCmdType;

//typedef enum _guard_type
//{
//    MkGbSetGuard,
//    MkGbResetGuard
//}MkGbGuardType;

typedef enum _play_control_type
{
    MkGbPlayControlInvalid,
    MkGbPlayControlPause,
    MkGbPlayControlReStore,
    MkGbPlayControlSeek,
    MkGbPlayControlSetSpeed
}MkGbPlayControlType;

typedef enum _protocol_type
{
    MkGbProtocolUdpInternal,
    MkGbProtocolTcpInternal,
    MkGbProtocolUdpExternal,
    MkGbProtocolTcpExternal
}MkGbProtocolType;

typedef enum _play_type
{
    MkGbRealPlay = 1,
    MkGbPlayback = 2,
    MkGbDownload = 3,
    MkGbDecoder = 4                 //gb decoder request
} MkGbPlayType;

typedef enum _stream_type
{
    MkGbStreamAudio = 1,             //only has audio  for voice intercom
    MkGbStreamVideo = 2,             //both has audio and video
} MkGbStreamType;


typedef enum _video_code_rate_type
{
    MkGbCodeRatefixed = 1,
    MkGbCodeRateVariable = 2
} MkGbCodeRateType;



typedef enum _audio_bit_rate
{
    MkGbCode5_3kbps = 1,  //5.3kbps
    MkGbCode6_3kbps = 2,  //6.3kbps
    MkGbCode8kbps = 3,  //8kbps
    MkGbCode16kbps = 4,  //16kbps
    MkGbCode24kbps = 5,  //24kbps
    MkGbCode32kbps = 6,  //32kbps
    MkGbCode48kbps = 7,  //48kbps
    MkGbCode64kbps = 8,   //64kbps
    MkGbCode12kbps = 9,   //12kbps
    MkGbCode80kbps = 10,  //80kbps
    MkGbCode96kbps = 11,  //80kbps
    MkGbCode112kbps,
    MkGbCode128kbps,
    MkGbCode160kbps,
    MkGbCode192kbps,
    MkGbCode224kbps,
    MkGbCode256kbps,
    MkGbCode288kbps,
    MkGbCode320kbps,
    MkGbCode10_8kbps,
    MkGbCode12_4kbps,
    MkGbCode14kbps,
    MkGbCode15_6kbps,
    MkGbCode17_2kbps,
    MkGbCode19_6kbps,
    MkGbCode21_2kbps,
    MkGbCode24_4kbps,
    MkGbCode23_05kbps,
    MkGbCode34kbps,
    MkGbCode48_61kbps
} MkGbAudioBitRate;

typedef enum _audio_sample_rate
{
    MkGbSampleRate8KHz = 1,  //8khz
    MkGbSampleRate14KHz = 2,  //14khz
    MkGbSampleRate16KHz = 3,  //16khz
    MkGbSampleRate32KHz = 4,   //32khz
    MkGbSampleRate7KHz,
    MkGbSampleRate11KHz,
    MkGbSampleRate12KHz,
    MkGbSampleRate22KHz,
    MkGbSampleRate24KHz,
    MkGbSampleRate44KHz,
    MkGbSampleRate48KHz,
    MkGbSampleRate64KHz,
    MkGbSampleRate88KHz,
    MkGbSampleRate96KHz,
    MkGbSampleRate12_8KHz,
    MkGbSampleRate25_6KHz,
    MkGbSampleRate38_4KHz
} MkGbAudioSampleRate;

typedef enum _record_secrecy_type
{
    MkGbRecordSecrecyTypeInvalid = -1,
    MkGbRecordSecrecyNot = 0,
    MkGbRecordSecrecy
}MkGbRecordSecrecyType;

//typedef enum _record_type
//{
//    MkGbRecordTypeInvilad = -1,
//    MkGbTimeRecord = 1,
//    MkGbAlarmRecord = 2,
//    MkGbManualRecord = 3,
//    MkGbAllRecord = 4
//}MkGbRecordType;

typedef enum _indistinct_query_type
{
    MkGbIndistinctQueryNone = 0,  //query frm device
    MkGbIndistinctQuery = 1,    //query from platform and device
}MkGbIndistinctQueryType;

typedef enum _find_record_location
{
    MkGbRecordLocationInvalid = 0,
    MkGbRecordLocationDevice = 1,
    MkGbRecordLocationCenter = 2,
    MkGbRecordLocationAll = MkGbRecordLocationDevice | MkGbRecordLocationCenter
}MkGbFindRecordLocation;

typedef enum _stream_number
{
    MkStreamMain = 0,
    MkStreamSub1,
    MkStreamSub2,
    MkStreamSub3,
    MkStreamSub4,
    MkStreamSub5,
    MkStreamSub6
}MkGbStreamNumber;

typedef enum _frame_mirror_type
{
    FrameMirrorNone = 0,
    FrameMirrorHorizontal = 1,
    FrameMirrorVertical = 2,
    FrameMirrorCenter = 3
}MkGbFrameMirrorType;

typedef enum _video_codec
{
    MkGbVideoMpeg4 = 1,
    MkGbVideoH264 = 2,
    MkGbVideoSvac = 3,
    MkGbVideo3Gp = 4,
    MKGbVideoH265 = 5
}MkGbVideoCodec;

typedef enum _video_frame_rate
{
    MkGbVideoFrame
}MkGbVideoFrameRate;

typedef enum _video_bit_rate_type
{
    MkGbVideoBitRateCbr,
    MkGbVideoBitRateVbr
}MkGbVideoBitRateType;

typedef enum _audio_codec
{
    MkGbAudioUnknow = -1,
    MkGbAudioNone = 0,
    MkGbAudioG711 = 1,
    MkGbAudioG723_1 = 2,
    MkGbAudioG729 = 3,
    MkGbAudioG722_1 = 4,
    MkGbAudioSvac = 5,
    MkGbAudioAac = 6
} MkGbAudioCodec;

typedef enum _device_alarm_type
{
    MkGbDeviceAlarmInvalid = 0,
    MkGbDeviceAlarmVideoLost = 1,
    MkGbDeviceAlarmTamper,
    MkGbDeviceAlarmFullDisk,
    MkGbDeviceAlarmHighTemperature,
    MkGbDeviceAlarmLowTemperature
}MkGbDeviceAlarmType;

typedef enum _video_alarm_type
{
    MkGbVideoAlarmInvalid = 0,
    MkGbVideoAlarmArtificialVideo = 1,
    MkGbVideoAlarmMovingDetection,
    MkGbVideoAlarmLegacyDetection,
    MkGbVideoAlarmObjectRemoved,
    MkGbVideoAlarmTripWireDetection,
    MkGbVideoAlarmIntrusionDetection,
    MkGbVideoAlarmRetrogradeMotion,
    MkGbVideoAlarmWanderDetection,
    MkGbVideoAlarmTrafficStatistics,
    MkGbVideoAlarmdensityDetection,
    MkGbVideoAlarmVideoAbnormal,
    MkGbVideoAlarmQuickMovement,
    MkGbVideoAlarmImageOcclusion
}MkGbVideoAlarmType;

typedef enum _device_fault_alarm_type
{
    MkGbDeviceFaultAlarmInvalid = 0,
    MkGbDeviceFaultAlarmDiskFault = 1,
    MkGbDeviceFaultAlarmFanFault
}MkGbDeviceFaultAlarmType;

typedef enum _gb_event_type
{
    MkGbEventIn = 1,
    MkGbEventOut = 2
}MkGbEventType;

//typedef enum _alarm_duty_status
//{
//    MkGbDutyStatusOnDuty = 1,
//    MkGbDutyStatusOffDuty,
//    MkGbDutyStatusAlarm
//}MkGbAlarmDutyStatus;

typedef enum _alarm_priority
{
    MkGbAlarmPriorityInvalid = -1,
    MkGbAlarmPriorityAll = 0,
    MkGbAlarmPriority1,
    MkGbAlarmPriority2,
    MkGbAlarmPriority3,
    MkGbAlarmPriority4
}MkGbAlarmPrority;

typedef enum _alarm_method
{
    MkGbAlarmMethodInvalid = -1,
    MkGbAlarmMethodAll = 0,
    MkGbALarmMethodPhone,
    MkGbAlarmMethodDevice,
    MkGbAlarmMethodSms,
    MkGbAlarmMethodGps,
    MkGbAlarmMethodVideo,
    MkGbAlarmMethodDeviceFault,
    MkGbAlarmMethodAther
}MkGbAlarmMethod;

typedef enum _subscription_status
{
    MkGbSubscribeStateUnknown = 0,
    MkGbSubscribeStatePending,
    MkGbSubscribeStateActive,
    MkGbSubscribeStateTerminated
}MkGbSubscriptionStatus;

typedef enum _subscription_reason
{
    MkGbSubscribeReasonDeactivated = 0,
    MkGbSubscribeReasonProbation,
    MkGbSubscribeReasonRejected,
    MkGbSubscribeReasonTimeout,
    MkGbSubscribeReasonGiveup,
    MkGbSubscribeReasonNoResource
}MkGbSubscriptionReason;

typedef enum _position_capability
{
    MkGbPositioCapabilityUnsupport = 0,
    MkGbPositioCapabilityGps,
    MkGbPositioCapabilityBeiDou
}MkGbPositioCapability;

//define from gb28181-2016 appendix F  sdp defines
typedef enum _video_resolution_type
{
    MkGbResolutionQCIF = 1,
    MkGbResolutionCIF = 2,
    MkGbResolution4CIF = 3,
    MkGbResolutionD1 = 4,
    MkGbResolution720P = 5,
    MkGbResolution1080P = 6
}MkGbVideoResolutionType;

//typedef enum _device_config_type
//{
//    MkGbDeviceConfigBasicParam,
//    MkGbDeviceConfigVideoParamOpt,
//    MkGbDeviceConfigSvacDecode,
//    MkGbDeviceConfigSvacEncode,
//    MkGbDeviceConfigVideoParamAttribute,
//    MkGbDeviceConfigVideoRecordPlan,
//    MkGbDeviceConfigVideoAlaramRecord,
//    MkGbDeviceConfigPictureMask,
//    MkGbDeviceConfigFrameMirror,
//    MkGbDeviceConfigAlarmReport,
//    MkGbDeviceConfigOSDConfig,
//    MkGbDeviceConfigSnapShotConfig,
//    MkGbDeviceConfigEnd
//}MkGbDeviceConfigType;

//typedef enum target_track_cmd
//{
//    MkGbTargetTrackAuto,
//    MkGbTargetTrackManual,
//    MkGbTargetTrackStop
//}MkGbTargetTrackCmd;



//typedef enum _ptz_precise_type
//{
//
//}MkGbPreciseType;


typedef struct _drag_zoom_param
{
    BOOL        bZoomIn;
    Uint32      nLength;
    Uint32      nWidth;
    Uint32      MidPointX;
    Uint32      MidPointY;
    Uint32      LengthX;
    Uint32      LengthY;
}MkGbDragZoomParam;

typedef struct _home_position_param
{
    BOOL        bEnabled;
    Uint32      ResetSecond;
    Uint32      PresetIndex;
}MkGbHomePositionParam;

typedef struct _video_param_opt_config_param
{
    MkVector<Uint8>     SupportDownloadSpeeds;
    MkVector<MkGbVideoResolutionType>   SupportResolutions;
}MkGbVideoParamOpt;

typedef struct _roi_item
{
    Uint32      ROISeq;
    Uint32      TopLeft;
    Uint32      BottomRight;
    Uint32      ROIQP;
}MkGbRIOItem;

typedef struct _svac_encode_roi_param
{
    Uint32                      ROIFlag;
    MkVector<MkGbRIOItem>       VecROI;
    Uint32                      BackGroundQP;
    Uint32                      BackGroundSkipFlag;
}MkGbSVACEncodeRoiParam;

typedef struct _svac_encode_audio_param
{
    BOOL                      AudioRecognitionFlag;
}MkGbSVACEncodeAudioParam;

typedef struct _svc_encode_param
{
    Uint32              SvcSpaceDomainMode;
    Uint32              SvcTimeDomainMode;
    MkString            SSvcRatioValue;
    Uint32              SvcSpaceSupportMode;
    MkString            SSvcRatioSupport;
}MkGbSvcEncodeParam;

typedef struct _surveillance_param
{
    BOOL                      TimeFlag;
    BOOL                      OsdFlag;
    BOOL                      AIFFlag;
    BOOL                      GisFlag;
}MkGbSurveillanceParam;

typedef struct _svc_decode_param
{
    Uint32              SvcStmMode;
    Uint32              SvcSpaceSupportMode;
    Uint32              SvcTimeSupportMode;
}MkGbSvcDecodeParam;

typedef struct _svac_decode_config_param
{
    Uint32                      SvcstmMode;
    MkGbSurveillanceParam       SurParam;
}MkGbSVACDecodeConfigParam;

typedef struct _find_record_param
{
    CMkTime                 StartTime;
    CMkTime                 EndTime;
    MkString                DeviceId;
    MkString                Name;
    MkString                FilePath;   //if empty not packet to xml
    MkString                Address;    //if empty not packet to xml
    MkGbRecordSecrecyType   SecrecyType; //if SecrecyTypeNone not packet to xml
    MkString                RecordType; //if RecordTypeNone not packet to xml
    MkString                RecorderID; //if empty not packet to xml
    Uint32                  FileSize;
    MkGbFindRecordLocation  RecordLocation; //if RecordRangeNone not packet to xml
    MkGbStreamNumber        StreamNumber;
    _find_record_param()
    {
        RecordLocation = MkGbRecordLocationInvalid;
        SecrecyType = MkGbRecordSecrecyTypeInvalid;
        //RecordType = MkGbRecordTypeInvilad;
        StreamNumber = MkStreamMain;
    }
}MkGbFindRecordParam;

typedef struct _alarm_info_param
{
    MkString                AlarmId;
    MkGbAlarmPrority        AlarmPrority;
    CMkTime                 AlarmTime;
    MkGbAlarmMethod         AlarmMethod;
    MkString                AlarmDesc;
    double                  Longitude;
    double                  Latitude;
}MkGbAlarmInfoParam;

typedef struct _alarm_subscribe_param
{
    MkGbAlarmPrority      StartAlarmPriority;
    MkGbAlarmPrority      EndAlarmPriority;
    MkGbAlarmMethod       AlarmMethod;
    MkString              AlaramType;
    CMkTime               StartAlarmTime;
    CMkTime               EndAlarmTime;
    _alarm_subscribe_param()
    {
        StartAlarmPriority = MkGbAlarmPriorityInvalid;
        EndAlarmPriority = MkGbAlarmPriorityInvalid;
        AlarmMethod = MkGbAlarmMethodInvalid;
    }
}MkGbAlarmSubscibeParam;

//typedef struct _catalog_item
//{
//    MkString        Id;             //channel id or alarm id
//    MkString        Name;
//    MkString        Manufacturer;
//    MkString        Model;
//    MkString        Owner;
//    MkString        CivilCode;
//    MkString        Block;
//    MkString        Address;
//    BOOL            Parental;
//    MkString        ParentID;
//    MkString        RegisterWay;
//    MkString        SecurityLevelCode;
//    BOOL            bSecrecy;
//    MkString        IPAddress;
//    Uint16          Port;
//    MkString        Password;
//    MkString        Status;
//    double          Longitude;
//    double          Latitude;
//    MkString        BusinessGroupId;
//
//    MkString        PtzType;
//    MkString        PhotoelectricImagingType;
//    MkString        CapturePositionType;
//    MkString        RoomType;
//    MkString        SupplyLightType;
//    MkString        DirectionType;
//    MkString        Resolution;
//    MkString        StreamNumberList;
//    MkString        DownloadSpeed;
//    Uint32          SVCSpaceSupportMode;
//    Uint32          SvcTimeSupportMode;
//    MkString        SSvcRatioSupportList;
//    Uint32          MobileDeviceType;
//    double          HorizontalFieldAngle;
//    double          VerticalFieldAngle;
//    double          MaxViewDistance;
//    MkString        GrassrootsCode;
//    Uint32          PointType;
//    MkString        PointCommonName;
//    MkString        Mac;
//    MkString        FunctionType;
//    MkString        EncodeType;
//    CMkTime         InstallTime;
//    MkString        ManagermentUnit;
//    MkString        ContactInfo;
//    Uint32          RecordSaveDays;
//    MkString        IndustrialClassfication;
//} MkGbCatalogItem;
//typedef MkMap<MkString, MkGbCatalogItem>  MkGbMapCatalog;
//typedef MkMapString MkGbCatalogItem;
//typedef MkVector<MkGbCatalogItem>   MkVector<MkMapString>;

typedef struct _preset_item
{
    Uint32          PresetId;                  //from 1 to 255
    MkString        PresetName;
} MkGbPresetItem;
typedef MkVector<MkGbPresetItem> MkGbVectorPreset;

//typedef struct _record_info_item
//{
//    Uint32                  SumNum;
//    MkString                DeviceId;
//    MkString                Name;
//    MkString                FilePath;
//    MkString                Address;
//    CMkTime                 StartTime;
//    CMkTime                 EndTime;
//    MkString                RecordType;
//    MkGbRecordSecrecyType   SecrecyType;
//    MkString                RecorderID;
//    Uint32                  FileSize;
//    MkString                RecordLocation;   //deviceid type
//    MkGbStreamNumber        StreamNumber;
//}MkGbRecordInfoItem;
//typedef MkVector<MkGbRecordInfoItem>  MkGbVectorRecordInfo;
//typedef MkMapString MkGbRecordInfoItem;
//typedef MkVector<MkGbRecordInfoItem>   MkGbVectorRecordInfo;

typedef struct _alarm_status_item
{
    MkString    AlarmId;
    MkString    DutyStatus;
}MkGbAlarmStateItem;

//typedef struct _device_status_param
//{
//    BOOL                            bOnline;
//    BOOL                            bStateOk;
//    MkString                        StateErrorReason;
//    BOOL                            bEncode;
//    BOOL                            bRecord;
//    CMkTime                         DeviceTime;
//    MkVector<MkGbAlarmStateItem>    VecAlarmState;
//}MkGbDeviceStatusParam;

//typedef struct _device_info_param
//{
//    MkString                        DeviceName;
//    MkString                        Manufacturer;
//    MkString                        Model;
//    MkString                        Firmware;
//    MkString                        DeviceType;
//    Uint32                          ChannelCount;
//    Uint32                          AlarmCount;
//    _device_info_param()
//    {
//        AlarmCount = ChannelCount = 0;
//    }
//}MkGbDeviceInfoParam;

typedef struct _mobile_position_item
{
    MkString                        DeviceId;
    CMkTime                         CaptureTime;
    double                          Longitude;
    double                          Latitude;
    double                          Speed;
    double                          Direction;
    double                          AltitudeMetre;
    double                          Height;
}MkGbMobilePositionItem;

typedef struct _ptz_precise_param
{
    double          Pan;  //0-360  
    double          Tilt;  //-30 90
    double          Zoom;
}MkGbPtzPreciseParam;

typedef struct _osd_text_item
{
    MkString    Text;
    Uint32      xPos;
    Uint32      yPos;
}MkGbOsdTextItem;

typedef struct _video_attribute_Item
{
    MkGbStreamNumber        StreamNumber;
    MkGbVideoCodec         Format;
    MkGbVideoResolutionType Resolution;
    MkGbVideoFrameRate           FrameRate;
    MkGbVideoBitRateType         BitRateType;
    Uint32                  BitRate;
}MkGbVideoAttributeItem;

typedef struct _record_time_segment
{
    Uint8      StartHour;
    Uint8      StartMin;
    Uint8      StartSec;
    Uint8      StopHour;
    Uint8      StopMin;
    Uint8      StopSec;
}MkGbRecordTimeSegment;

typedef struct _record_schedule_item
{
    Uint32      WeekDayNum;
    MkVector<MkGbRecordTimeSegment> VecTimeSegment;
}MkGbRecordScheduleItem;

typedef struct _picture_mask_region
{
    Uint8       Seq;        //1-4
    Uint32      LeftX;
    Uint32      LeftY;
    Uint32      RightX;
    Uint32      RightY;
}MkGbPictureMaskRegion;

typedef struct _cruise_track_item
{
    Uint32      Number;
    MkString    Name;
}MkGbCruiseTrackItem;

typedef struct _cruise_point_item
{
    Uint8       PresetIndex;
    Uint32      StaySec;
    Uint8       Speed;
}MkCrusePointItem;

typedef struct _sd_card_info_item
{
    Uint32      Id;
    MkString    HddName;
    MkString    Status;
    Uint32      FormatProgress;
    Uint32      CapacityMB;
    Uint32      FreeSpaceMB;
}MkGbSDCardInfoItem;


typedef struct _device_upgrade_param
{
    MkString        Firmware;
    MkString        FileUrl;
    MkString        Manufacturer;
    MkString        SessionId;
}MkGbDeviceUpGradeParam;

//typedef MkPair<MkString, MkString>   GbMessageNode;
//typedef MkVector<GbMessageNode>      GbMessageSet;
//typedef MkVector<GbMessageSet>       VecGbMessageSet;

typedef struct _gb_message
{
    MkMapString                                         MainParam;
    MkMap<MkString, struct _gb_message>                 MapMessage;
    MkString                                            ChildKey;
    MkString                                            ItemName;
    MkVector<struct _gb_message>                        VecChildren;
    MkVector<MkPair<MkString, MkString>>                InfoParam;
    MkVector<MkPair<MkString, MkString>>                SnapShotParam;
}MkGbMessage;

typedef enum _gb_request_type
{
    MkGbRequestMessage,
    MkGbRequestDeviceAuthor,
    MkGbRequestSubscribe,
    MkGbRequestNotify,
    MkGbRequestRegister,
    MkGbRequestInvite,
    MkGbRequestInviteInfo,
    MkGbRequestAck,
    MkGbRequestBye,
    MkGbReqeustInfo
}MkGbRequestType;

class MkApi CMkGbRequest
{
public:
    CMkGbRequest(const MkGbRequestType& Event);
    virtual ~CMkGbRequest();
    MkString            m_RouterId;             //to uri user name
    MkString            m_DstId;                //sip uri user name
    MkString            m_FromId;               //from uri user name
    MkGbRequestType     m_RequestType;
    MkGbMessage         m_Message;
};

class MkApi CMkGbResponse
{
public:
    CMkGbResponse();
    virtual ~CMkGbResponse();
    MkGbMessage         m_Message;
};

class MkApi CMkGbMessageRequest : public CMkGbRequest
{
public:
    CMkGbMessageRequest();
    MkString    m_DeviceId;           //xml DeviceID
    MkString    m_MessageType;        //query  control or notify
    MkString    m_CmdType;            //xml CmdType
};

class MkApi CMkGbSubscribeRequest : public CMkGbRequest
{
public:
    CMkGbSubscribeRequest();
    MkString    m_DeviceId;
    MkString    m_MessageType;
    MkString    m_CmdType;
    MkString    m_SubscribeId;
    Uint32      m_Expires;
    MkString    m_Event;
};

class MkApi CMkGbNotifyRequest : public CMkGbRequest
{
public:
    CMkGbNotifyRequest();
    MkString    m_DeviceId;
    MkString    m_MessageType;
    MkString    m_CmdType;
    MkString    m_SubscribeId;
    Uint32      m_Expires;
    MkString    m_Event;
    MkString    m_State;  //active or terminated
};

class MkApi CMkGbInviteReqeust : public CMkGbRequest
{
public:
    CMkGbInviteReqeust();
    MkString    m_SessionId;
    MkString    m_SubjectSource;
    MkString    m_OfferSdp;
};

class MkApi CMkGbByeReqeust : public CMkGbRequest
{
public:
    CMkGbByeReqeust();
    MkString    m_SessionId;
};

class MkApi CMkGbAckReqeust : public CMkGbRequest
{
public:
    CMkGbAckReqeust();
    MkString    m_SessionId;
    MkString    m_RemoteSdp;
};

class MkApi CMkGbInviteInfoRequest : public CMkGbRequest
{
public:
    CMkGbInviteInfoRequest();
    MkString    m_SessionId;
    MkGbPlayControlType m_ControlType;
    float   m_fSleep;
    Uint32 m_DragSecond;
};

class MkApi CMkGbMessageResponse : public CMkGbResponse
{
public:
    CMkGbMessageResponse();
    Uint32      m_SumNum;
};

class MkApi CMkGbSubscribeResponse : public CMkGbResponse
{
public:
    CMkGbSubscribeResponse();
    MkString    m_SubscribeId;
};

class MkApi CMkGbNotifyResponse :public CMkGbResponse
{
public:
    CMkGbNotifyResponse();
    MkString    m_SubscribeId;
};

class MkApi CMkGbInviteInfoResponse : public CMkGbResponse
{
public:
    CMkGbInviteInfoResponse();
    MkString    m_SessionId;
    MkGbPlayControlType m_ControlType;
    float   m_fSleep;
    Uint32 m_DragSecond;
};

class MkApi CMkGbDeviceAuthorRequest : public CMkGbRequest
{
public:
    CMkGbDeviceAuthorRequest();
    MkString        m_RegisterId;           //re flash register has same id
    MkString        m_AuthorType;
    MkString        m_UserName;
    MkString        m_Realm;
    MkString        m_Nonce;
    MkString        m_Uri;
    MkString        m_Response;
    MkString        m_Algorithm;
    MkString        m_DeviceHost;
    Uint16          m_DevicePort;
    Uint32          m_Expires;
};

class MkApi CMkGbDeviceAuthorResponse : public CMkGbResponse
{
public:
    CMkGbDeviceAuthorResponse();
    BOOL        m_bRedirect;
    MkString    m_RedirectId;
    MkString    m_RedirectHost;
    Uint16      m_RedirectPort;

    MkString    m_RegisterId;
    MkString    m_AuthType;
    MkString    m_Realm;
    MkString    m_Algorithm;
    MkString    m_Nonce;
    MkString    m_Uri;
    BOOL        m_Stale;
    Uint32      m_Expires;
};

class MkApi CMkGbInviteResponse : public CMkGbResponse
{
public:
    CMkGbInviteResponse();
    MkString                m_SessionId;
    MkString                m_AnwserSdp;
    EventResponseCallback   m_EventResCb;
};

//class MkApi CMkGbUtil
//{
//public:
//    ~CMkGbUtil();
//    static CMkGbUtil& GetInstance() { return m_Instance; }
//
//    //const MkString& GetStringMessageType(const MkGbMessageType& MessageType) const;
//    //const MkString& GetStringRecordCmdType(const MkGbRecordCmdType& CmdType) const;
//    //const MkString& GetStringStatusType(const MkGbStatusType& StatusType) const;
//    //const MkString& GetStringResultType(const MkGbResultType& ResultType) const;
//    //const MkString& GetStringGuardType(const MkGbGuardType& GuardType) const;
//    //const MkString& GetStringTargetTrackCmd(const MkGbTargetTrackCmd& TargetTrackCmd) const;
//    //const MkString& GetStringVideoFormat(const MkGbVideoCodec& Format) const;
//    //const MkString& GetStringVideoResolutionType(const MkGbVideoResolutionType& ResolutionType) const;
//    //const MkString& GetStringFrameRate(const MkGbVideoFrameRate& FrameRate) const;
//    //const MkString& GetStringBitRateType(const MkGbVideoBitRateType& BitRateType) const;
//    //const MkString& GetStringDeviceConfigType(const MkGbDeviceConfigType& ConfigType) const;
//    //const MkString& GetStringPtzCmd(const MkGbPtzCommandType& GbType) const;
//    //Uint32 GetGbPtzCmdType(const MkString& strType, MkGbPtzCommandType& GbType) const;
//    //Uint32 GetGbRecordType(const MkString& strType, MkGbRecordType& GbType) const;
//    //const MkString& GetStringRecordType(const MkGbRecordType& GbType) const;
//    //Uint32 GetGbAlarmDutyStatus(const MkString& strStatus, MkGbAlarmDutyStatus& GbStatus) const;
//    //const MkString& GetStringAlarmDutyStatus(const MkGbAlarmDutyStatus& GbStatus) const;
//    //Uint32 GetGbDeviceConfigType(const MkString& strType, MkGbDeviceConfigType& GbType) const;
//    //Uint32 GetGbPositioCapability(const MkString& strCapability, MkGbPositioCapability& GbCapability) const;
//    //const MkString& GetStringPositioCapability(const MkGbPositioCapability& GbCapability) const;
//    //Uint32 GetGbResolutionType(const MkString& strType, MkGbVideoResolutionType& GbType) const;
//    //const MkString& GetStringAudioCodec(const MkGbAudioCodec& Codec) const;
//    //const MkString& GetStringAudioSampleRate(const MkGbAudioSampleRate& SampleRate) const;
//    //const MkString& GetStringAudioBitRate(const MkGbAudioBitRate& BitRate) const;
//    Uint32 GetGbControlType(const MkString& strType, MkGbPlayControlType& GbType) const;
//    MkString GetStrControlType(const MkGbPlayControlType& GbType) const;
//    //Uint32 GetGbAlarmPrority(const MkString& strPrority, MkGbAlarmPrority& GbPrority) const;
//    //Uint32 GetGbAlarmMethod(const MkString& strAlarmMethod, MkGbAlarmMethod& GbMethod) const;
//protected:
//private:
//    CMkGbUtil();
//    static CMkGbUtil                                    m_Instance;
//    MkString                                            m_EmptyString;
//    //MkUnorderedMap<MkString, MkGbDeviceConfigType>      m_MapDeviceConfig;
//    //MkUnorderedMap<Uint32, MkString>                    m_MapMessageType;
//    //MkUnorderedMap<MkString, MkGbPtzCommandType>        m_MapPtzCommand;
//    //MkUnorderedMap<MkString, MkGbPlayControlType>       m_MapPlayControlType;
//};

#endif
